/**
 * Created by Administrator on 13-12-27.
 */
Ext.define("qjtravel.view.HomeCategoryView",{
    extend:"Ext.DataView",
    xtype:"homeCategoryView",
    config:{
        id: 'click_category',
        store: 'Category',
        emptyText: '',
        scrollable: true,
        /*itemTpl: '<tpl if="display==3 || display==4">' + '<div style="width:50%;height:92%;padding:5px 5px 0 5px; position:relative; float:left" id="image">' +
         '<img src="{iconUrl}" height="50%" width="100%" />' +
         '<div style="position:absolute; color: #fff; bottom:10px; left:12px; font-size: 14px">{name}</div>'
         + '</div>' + "<tpl else>" + '<div style="width:25%;height:92%;padding:5px 5px 0 5px; position:relative; float:left">' +
         '<img src="{iconUrl}" height="50%" width="100%" />' +
         '<div style="position:absolute; color: #fff; bottom: 10px; left:12px;  font-size: 14px">{name}</div>' + '</div>' + "</tpl>",*/
        itemTpl: '<div class="homeCategoryItem" ><img src="{iconUrl}"/><span style="position:relative; color: #fff; top: -25px;  font-size: 16px; font-weight:bold;">{name}</span></div>',
        listeners: {
            painted: function (dataview) {
                var category = Ext.getStore('Category');
                if (category.find('cadid', 6) == -1) {
                    category.load({
                        params: {
                            cadid: 6
                        }
                    });
                }
                var bodyW = document.body.clientWidth;
                var baseMath=(bodyW>600||bodyW<400)?1.6: 1.55;
                dataview.setHeight(bodyW/3*baseMath)
                var dataH = dataview.getHeight();
                var intTime = setInterval(function () {
                    if (document.getElementsByClassName("homeCategoryItem").length > 0) {
                        for (var i = 0; i < document.getElementsByClassName("homeCategoryItem").length; i++) {
                            document.getElementsByClassName("homeCategoryItem")[i].style.height = (dataH / 2) + "px";
                            //console.log(document.getElementsByClassName("homeCategoryItem")[i].style.height)
                        }
                        clearInterval(intTime);
                    }
                }, 50)
            }
        }

    }
})

